/**
 * @author mili
 */

/*
	variables to contain files' names
*/
var incidentFiles, F3Files, M4Files, M7Files;

function display(){
	var tl = document.timestamp.timeline;
	var text = timeMap[document.timestamp.timeline.options[tl.selectedIndex].text];
	var time = getStartTime(text);
	loadFiles(time);
	// for incidents array
	// call incident.js methods to parse
	getIncidents(incidentFiles);
	
	pickLastF3(F3Files);
	pickLastM4(M4Files);
	pickLastM7(M7Files);
	get_Cat2_Roads();
	hashF3M4M7();
	
	
	// comment these three lines to integrate heatmap and markers
	/**/
	initialize();
	changeRadius();
	changeGradient();
	/**/
}



// call to load incident json files based on select time period
// load the f3, m4 and m7 json files respectively
function loadFiles(time){
	var ret = (function(){
		var obj = null;
		$.ajax({
			'async':false,
			'global':false,
			'url':server_url+"?type=getIncidentsWithinOneHour&flag=no-debug&time="+time,
			'success':function(data){
				obj = data;
			}
		});
		return obj;
	})();
	
	/*
		Related Incident Files within One Hour	
	*/
	incidentFiles = JSON.parse(ret);
	
	ret = (function(){
		var obj = null;
		$.ajax({
			'async':false,
			'global':false,
			'url':server_url+"?type=getF3&flag=no-debug&time="+time,
			'success':function(data){
				obj = data;
			}
		});
		return obj;
	})();
	
	/*
		Related F3 Files within One Hour
	*/
	F3Files = JSON.parse(ret);
	
	ret = (function(){
		var obj = null;
		$.ajax({
			'async':false,
			'global':false,
			'url':server_url+"?type=getM4&flag=no-debug&time="+time,
			'success':function(data){
				obj = data;
			}
		});
		return obj;
	})();
	
	/*
		Related M4 Files within One Hour
	*/
	M4Files = JSON.parse(ret);
	
	ret = (function(){
		var obj = null;
		$.ajax({
			'async':false,
			'global':false,
			'url':server_url+"?type=getM7&flag=no-debug&time="+time,
			'success':function(data){
				obj = data;
			}
		});
		return obj;
	})();
	
	/*
		Related M7 Files within One Hour
	*/
	M7Files = JSON.parse(ret);
}
